package com.hyt.it.ogt.kq.common.enums;

import com.hyt.loginfo.model.User;

import cn.hutool.core.util.StrUtil;

/***
 * 用户类型枚举
 *
 */
public enum UserTypeEnum  {
    
	ADMIN("ADMIN", "后台管理端用户"),
	OPERATE_ADMIN("OPERATE_ADMIN", "运营管理端用户"),
	OFFICE_ADMIN("OFFICE_ADMIN", "考试组织者用户"),
	EXAMINEE("EXAMINEE", "考生"),
	DEVELOPERS("DEVELOPERS", "开发商");
    
    public final String code;
    
    public final String desc;

    private UserTypeEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    

    public String getCode() {
		return code;
	}



	public String getDesc() {
		return desc;
	}



    public static String getDescByCode(String code) {
        for (UserTypeEnum bl : UserTypeEnum.values()) {
            if (bl.getCode().equals(code)) {
                return bl.getDesc();
            }
        }
        return "";
    }

    public static UserTypeEnum getEnumByCode(String code) {
        for (UserTypeEnum bl : UserTypeEnum.values()) {
            if (bl.getCode().equals(code)) {
                return bl;
            }
        }
        return null;
    }
    
    public static Boolean isManager(User user) {
        if (null == user || StrUtil.isEmptyIfStr(user.getId())) {
            return Boolean.FALSE;
        }
        String userType = user.getUsertype();
        if (StrUtil.isNotEmpty(userType) && OFFICE_ADMIN.getCode().equals(userType)) {
            return Boolean.TRUE;
        }
        return Boolean.FALSE;
    }
}
